package com.ruike.alisurface.utils;

import android.text.TextUtils;

import com.voodoo.lib_http.ApiTools;
import com.voodoo.lib_http.DownloadListener;

import java.io.File;

/**
 * Author：voodoo
 * CreateTime：2021/07/07 007 下午 01:36
 * Description：
 */
public class DownloadFileUtils implements DownloadListener {

    private ApiTools apiTools;

    /**
     * 下载文件
     *
     * @param downloadUrl
     * @param savePath
     * @param saveFileName
     */
    public void startDownloadFile(String downloadUrl, String savePath, String saveFileName) {
        if (TextUtils.isEmpty(downloadUrl) || TextUtils.isEmpty(savePath) || TextUtils.isEmpty(saveFileName)) {
            throw new RuntimeException(String.format("下载地址或者保存文件地址为空\nDownloadUrl=%s\nSavePath=%s\nSaveFileName=%s", downloadUrl, savePath, saveFileName));
        }
        apiTools = new ApiTools();
        apiTools.download(downloadUrl, savePath, saveFileName, this);
    }

    @Override
    public void onDownloadStart(String url, int id) {

    }

    @Override
    public void onDownloading(String url, long progress, long total, int id) {

    }

    @Override
    public void onDownloadComplete(String url, int id) {

    }

    @Override
    public void onDownloadSuccess(String url, File downloadFile, int id) {

    }

    @Override
    public void onDownloadFail(String url, String errorMsg, int id) {

    }

}
